<template>
	<view class="container">
		<!-- 顶部 -->
		<view class="header-box">
			<view class="uni-margin-wrap">
				<swiper class="swiper" circular :indicator-dots="true" :autoplay="true">
					<swiper-item v-for="url in detailData.imageList" :key="url">
						<img style="width: 100%; height: 100%; " :src="url" alt="" srcset="" />
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!-- 分院详情 -->
		<view class="branch-box-content">
			<view class="branch-court" style="margin-top: 0;">
				<view class="header-title">
					<view class="left-box" style="display: flex;justify-content: space-between;width: 100%;">
						<view>{{detailData.storeName}}</view>
						<!-- <view style="font-weight: 400;font-size: 24rpx;color:#95989D" @click="moreClick">更多> </view> -->
					</view>
					<!-- <view class="right-box">更多 <u-icon name="arrow-right" color="#999" size="12"></u-icon></view> -->
				</view>
				<view class="btn-box">
					<!-- <view v-for='item in detailData.storeTagList' class="tag"><u-tag :text="item"></u-tag></view> -->
				</view>
				<view style="padding: 20rpx 0rpx">
					<u-rate readonly active-color="#FFD600" :count="count" v-model="detailData.score"></u-rate>
				</view>
				<view class="text-content">
					<view>
						<view style="display: flex;justify-content: space-between;margin-bottom: 10rpx;">
							<view>服务人次:{{detailData.serviceNum?detailData.serviceNum:'0'}}次</view>
							<view>营业时间:{{detailData.businessStartTime}} - {{detailData.businessEndTime}}</view>
						</view>
						<view style="margin-bottom: 10rpx;display: flex;justify-content: space-between;">
							<view style="margin-right: 20rpx">
								电话：{{detailData.telephoneList[0]}}
							</view>
							<view> 距离：{{detailData.distance}}</view>
						</view>
						<view style="margin-bottom: 10rpx;"> 地址:{{detailData.address}} </view>

					</view>
				</view>

			</view>
		</view>

		<!-- 分院详情 -->
		<!-- 发友点评 -->
		<view class="outside-box">
			<view class="message-box">
				<view style="padding: 20rpx 40rpx;font-size: 32rpx;text-align: left;font-weight: 600;">发友评论</view>
				<view class="message-list">
					<view class="message-item" v-for='item in reviewList.content' :key='item.id'>
						<view class="top-box">
							<img src="https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF" alt="">
							<view class="text-name">
								<view class="title-flex">
									<view>{{item.weUserName}}</view>
									<view>
										<view @click="isLikeClick('Y',item.id)" v-if="item.isLike === 'N'">
											<u-icon size="36rpx" name="heart"></u-icon>
										</view>
										<view v-else>
											<u-icon @click="isLikeClick('N',item.id)" color="#e45656" name="heart-fill"
												size="36rpx"></u-icon>
										</view>
									</view>
								</view>
								<view style="font-size: 24rpx;">{{item.publicTime}}</view>
							</view>
						</view>
						<view class="center-box">
							<view>{{item.content}}</view>
							<view v-if='item.imageList && item.imageList.length>0'>
								<u-album :urls="item.imageList"></u-album>
							</view>
						</view>
						<view class="bottom-box">
						</view>
					</view>
				</view>
			</view>

		</view>

	</view>
</template>
<script>
	import {
		AllList,
		queryScheduleDoctor,
		storeInfo,
		queryDayData,
		evaluateList,
		evaluateArea,
		evaluateLike,
		evaluateUnlike
	} from "@/api/axios/MakeAnAppointmentCenter.js";
	import store from '@/store/index.js'
	export default {
		data() {
			return {
				swiperList: [
					"https://cdn.uviewui.com/uview/swiper/swiper1.png",
					"https://cdn.uviewui.com/uview/swiper/swiper2.png",
					"https://cdn.uviewui.com/uview/swiper/swiper3.png",
				],
				doctorList: [],
				timeList: [{
					week: "星期一",
					day: "8-16"
				}],
				count: 5,
				value: 2,
				list: [],
				current: 0,
				timeShow: false,
				currentTime: "",
				detailData: {},
				colorIndex: 0,
				reviewList: [],
				openId: ""
			};
		},
		mounted() {},
		components: {},
		async onLoad(data) {
			console.log(data.storeId, 'data.storeId');
			let _this = this;
			this.storeId = data.storeId
			let mapData = store.state.mapData
			this.openId = uni.getStorageSync("openId");
			let localCoordinate = ''
			if (mapData.location) {
				localCoordinate = mapData.location.lng + ',' + mapData.location.lat
			}
			this.detailData = await storeInfo({
				params: {
					deptId: data.storeId,
					localCoordinate: localCoordinate,
					mode: 'walking'
				}
			})
			this.reviewList = await evaluateArea({
				params: {
					openId: this.openId,
					storeId: data.storeId,
				}
			})
			console.log(this.reviewList);


		},
		methods: {
			isLikeClick(isFlag, id) {
				let _this = this;
				if (isFlag === "Y") {
					evaluateLike({
						openId: this.openId,
						id: id,
					}).then((res) => {
						_this.reviewList.content.forEach(item => {
							if (item.id === id) {
								item.isLike = 'Y'
								this.clue({
									action: '4',
									eventType: '1',
								})
							}
						})
					});
				} else {
					evaluateUnlike({
						openId: this.openId,
						id: id,
					}).then((res) => {
						console.log(_this.reviewList);
						_this.reviewList.content.forEach(item => {
							if (item.id === id) {
								item.isLike = 'N'
							}
						})
					});
				}
			},
			publishMethod() {},
			evaluateMethod() {
				console.log('evaluateMethod');
			},
		}
	}
</script>
<style lang='scss'>
	@import "index.scss";
</style>